package solution;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @author : wenchao.long
 * @date : Created in 2023-12-19 下午 3:23 周二
 * @description : 两数之和
 */
public class No1 {

	public int[] twoSum(int[] nums, int target) {
		Map<Integer, Integer> result = new HashMap<>();
		for (int i = 0; i < nums.length; i++) {
			if (result.containsKey(target - nums[i])) {
				return new int[]{result.get(target - nums[i]), i};
			}
			result.put(nums[i], i);
		}
		return null;
	}

	public static void main(String[] args) {
		No1 no1 = new No1();
		int[] ints = no1.twoSum(new int[]{2, 7, 11, 15}, 9);
		System.out.println(Arrays.toString(ints));

		String string = "20231219";
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < string.length(); ++i) {
			sb.append(string.charAt(i));
			if (i == 3 || i == 5) {
				sb.append("-");
			}
		}

		System.out.println(sb.toString());

		DecimalFormat decimalFormat = new DecimalFormat("##0.00%");

		String format = decimalFormat.format(new BigDecimal("0.9999"));
		System.out.println(format);
	}
}
